home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000086_icon-group-sender _Tue Apr 19 14:32:34 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
2KB
Received: by cheltenham.cs.arizona.edu; Tue, 19 Apr 1994 15:53:29 MST
Date: Tue, 19 Apr 1994 14:32:34 -0500
From: John David Stone <stone@math.grin.edu>
Message-Id: <199404191932.OAA00763@russell.math.grin.edu>
To: rjhare@festival.ed.ac.uk
Cc: icon-group@cs.arizona.edu
In-Reply-To: R J Hare's message of 19 Apr 94 14:03:10 BST <9404191403.aa04644@uk.ac.ed.festival>
Subject: random numbers
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
R. J. Hare writes:
> I have a program in which I have an integer which marks the
> upper end of a range from which I wish to randomly select a value. I am
> using:
>
> i:=?range
>
> so, if I have previously set range to (say) 13, I should get i in the
> range 1..13. In fact, I am getting i equals 1 or 3, ie: ? is apparently
> treating range as a 2 character string and returning randomly the value
> of the 1st or 2nd character in the string. Is this behaviour correct?
It is if the value of `range' is really a string. How did this
variable acquire its value in the first place? If it was typed in from
the keyboard in response to a prompt, e.g.,
writes("Number, please: ")
range := read()
then the value that is assigned to `range' really is a string, and if you
want to deal with an integer you should change the second statement to
something like
(range := integer(read())) | stop("non-integer input")
------ John David Stone - Lecturer in Computer Science and Philosophy -----
-------------- Manager of the Mathematics Local-Area Network --------------
-------------- Grinnell College - Grinnell, Iowa 50112 - USA --------------
-------- stone@math.grin.edu - (515) 269-3181 - stone@grin1.bitnet --------